feature: structured trade history data, portfolio summary, bug fixes#358
Merged
feature: structured trade history data, portfolio summary, bug fixes#358
Conversation
… exposure metrics
…without valid price
su8su
approved these changes
Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Pull Request Template
1. Related Issue
Closes # (issue number)
Type of Change (select one)
Bug Fix, New Feature
3. Description
Composer — robust LLM parsing:
_call_llmnow accepts agent results that are already aLlmPlanProposal, adict, or a JSON/text string. It attempts to validate/parse intoLlmPlanProposaland falls back to a minimal proposal that preserves the raw model output inrationale.Composer — safety for missing prices & conservative BP accounting:
_normalize_quantitynow blocks exposure-increasing trades when no valid price is available, only allowing reduce-only (flattening) actions.Portfolio settlement correctness:
avg_exec_price, thenexit_price, thenentry_price(fallback to market snapshot) when computing notional and mark price.total_value) equalsaccount_balance + net_exposureafter closes; fixes the observed mismatch after full liquidation.Logs & diagnostics: composer and portfolio code now emit clear warnings/errors when encountering missing/invalid model or price data and preserve raw LLM outputs in
rationalefor auditing.Summary: these changes make decision-time sizing and portfolio accounting safe and deterministic: they prevent exposure creation when market prices are unavailable, ensure buying-power is conservatively estimated, and make cash/realized PnL settle correctly — plus they add tests and better logging so the behaviors are observable and reproducible.
4. Testing
5. Checklist